﻿@using IEMSOFT.EasyHotel.Admin.Models;
@using IEMSOFT.EasyHotel.Common;
@using IEMSOFT.Foundation;
@{
    ViewBag.Title = "入住状态";
}
@section header
{
}
<form id="fmSearchCheckinStatus">
    <div class="fitem">
        <label>所在分店:</label>
        <select class="easyui-combobox" name="subHotelId"
            data-options="url:'/subhotel/option?defaultText=%E5%85%A8%E9%83%A8',method:'get',valueField:'value',textField:'text'">
        </select>
    </div>
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="searchCheckinStatus()" style="width: 90px">查询</a>
</form>
<br />
<table id="dgCheckinStatus" class="easyui-datagrid" pagination="true" 
    rownumbers="true" fitcolumns="true" singleselect="false" striped="true" ctrlselect="true"
    pagelist="[25,40,60,80,100,150,200]" pagesize="25"  data-options="showFooter: true">
    <thead>
        <tr>
            <th field="subHotelName">分店</th>
            <th field="roomNo">房间</th>
            <th field="roomTypeName">房型</th>
            <th field="roomStatusName">状态</th>
            <th field="customerCheckinDate">入住时间</th>
            <th field="customerName">房客姓名</th>
            <th field="customerTravelAgency">房客来源</th>
            <th field="singlePrice">单价</th>
            <th field="customerDeposit">押金</th>
            <th field="customerPayType">支付方式</th>
            <th field="billCreateUserFullName">创建者</th>
        </tr>
    </thead>
</table>
@section Scripts
{
    <script type="text/javascript">
        $(function () {
            $('#dgCheckinStatus').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', []);
        });
        function searchCheckinStatus() {
            var msgTitle = '入住状态';
            var actionUrl = '/room/SearchCheckinStatus';
            $.post(actionUrl,
                   $('#fmSearchCheckinStatus').serialize(),
                   function (data) {
                       var msg = '';
                       if (data.msg.length != 0) {
                           $.each(data.msg, function () {
                               msg = data.msg + msg + '<br/>';
                           });
                           $.messager.alert(msgTitle, msg, 'error');
                       }
                       else {
                           var result = {
                               total: data.data.length,
                               rows: data.data,
                               footer:[{
                                   subHotelName: "空闲房间数：",
                                   roomNo: 0,
                                   roomTypeName: "入住房间数：",
                                   roomStatusName: 0,
                                   customerCheckinDate: "维修房间数：",
                                   customerName:0
                               }]
                          }
                           $.each(data.data, function (index, value) {
                               if (value.roomStatusId == roomStatusType.Normal) {
                                   result.footer[0].roomNo = result.footer[0].roomNo + 1;//空房间数
                               }
                               if (value.roomStatusId == roomStatusType.CheckedIn) {
                                   result.footer[0].roomStatusName = result.footer[0].roomStatusName + 1;
                               }
                               if (value.roomStatusId == roomStatusType.IsMending) {
                                   result.footer[0].customerName = result.footer[0].customerName + 1;//维修
                               }
                          });
                          $('#dgCheckinStatus').datagrid('loadData', result);
                           $('#dgCheckinStatus').datagrid('getPager').pagination('select');
                       }
                   });
        }
    </script>
}